package com.jmu.posms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jmu.posms.dto.AddressDto;
import com.jmu.posms.exception.ServiceException;
import com.jmu.posms.pojo.Address;
import com.jmu.posms.service.AddressService;
import com.jmu.posms.dao.AddressMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
* @author 青暮月上
* @description 针对表【address】的数据库操作Service实现
* @createDate 2022-06-24 21:20:09
*/
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService{
    @Resource
    AddressMapper addressMapper;

    @Override
    public Address add(AddressDto addressDto) {
        Address address = new Address();
        BeanUtils.copyProperties(addressDto,address);
        address.setId(UUID.randomUUID().toString());
        try{
            addressMapper.insert(address);
        }catch (Exception e){
            throw new ServiceException("600","插入地址失败");
        }
        return address;
    }
}




